<template>
    <view>
        <view class="header">
            <u-navbar :is-back="false" title="分类"></u-navbar>
        </view>

        <view class="clazz u-flex bg_w u-col-top" :style="{height:sys_height}">
            <view class="clazz_left w_25 h_100">
                <scroll-view :scroll-y="true" class="h_100">
                    <view class="left_list">
                        <view @click="toggleLeft(index)" class="left_item p_col_40 u-text-center u-rela"
                            :class="{left_active:index == left_cur}" v-for="(item,index) in clazz_list" :key="index">
                            <text>{{item.name}}</text>
                        </view>
                    </view>
                </scroll-view>
            </view>
            <view class="clazz_right u-flex-1 h_100">
                <scroll-view :scroll-y="true" class="h_100">

                    <view class="right_list u-flex u-flex-wrap p_row_30 u-m-t-30">
                        <view class="right_item w_33 m_b_20" v-for="(item,index) in clazz_list[left_cur].foods" @click="$x.to(`clazz/goods-list?keyword=${item.name}`)">
                            <view class="item_img">
                                <u-image border-radius="10" width="100%" height="140" :src="item.icon" mode="aspectFit"></u-image>
                            </view>
                            <view class="u-text-center u-font-26 color_6 u-m-t-10">
                                {{item.name}}
                            </view>
                        </view>
                    </view>
                </scroll-view>
            </view>
        </view>

    </view>
</template>

<script>
    import clazzList from '@/common/enum/clazz.json'
    export default {
        data() {
            return {
                left_cur: 0,
                sys_height: 0,
                clazz_list: clazzList,
            };
        },
        onLoad() {
            this.getSysHeight()
        },
        methods: {
            toggleLeft(index) {
                this.left_cur = index
            },
            getSysHeight() {
                this.sys_height = this.$u.sys().windowHeight
                console.log(this.sys_height);
            }
        },
    };
</script>



<style lang="scss" scope>
    .clazz {
        &_left {
            .left_item {
                background-color: #f6f6f6;

                &.left_active {
                    font-weight: 700;
                    font-size: 30;
                    background-color: #fff;

                    &::before {
                        content: "";
                        position: absolute;
                        top: 65%;
                        left: 50%;
                        transform: translateX(-50%);
                        width: 30%;
                        height: 6rpx;
                        background-color: $u-type-primary;
                        border-radius: 3rpx;
                    }
                }
            }

        }
    }
</style>
